package com.hsogoo.collate.batch;

import com.hsogoo.collate.domain.CollateFieldsDO;
import com.hsogoo.collate.mapper.CollateFieldsMapper;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author huangsaigang
 * Created @2019-10-30.
 */
@Slf4j
@Setter
public class CollateWriter implements ItemWriter<CollateFieldsDO> {

    private CollateFieldsMapper collateFieldsMapper;

    @Override
    public void write(List<? extends CollateFieldsDO> items) throws Exception {

        for(CollateFieldsDO fieldsDO : items){
            collateFieldsMapper.addCollateFields(fieldsDO);
        }
        log.info("save collate file to database success");
    }

}
